<?php
	require_once 'models/models_chitietnhap.php';
	$mod = $_GET['mod'];
	$obctnhap = new models_chitietnhap();
	require_once 'models/models_hang.php';
	$obHang = new models_hang();
	require_once 'models/models_mathang.php';
	$obMh = new  models_mathang();
	switch ($mod){
		case 'ctnhap':{
			$data['list'] = $obctnhap->_listCTNhap();
			$data['listhang'] = $obHang->_listhang();
			$data['listmathang'] = $obMh->listMatHang();
			require 'views/admin/chitietnhap/index.php';
			break;
		}
		case 'add_ctnhap':{
			if($_POST){
				$obctnhap->_addCTNhap($_POST['cmb_hang'], $_POST['cmb_mathang'], $_POST['dongia'], $_POST['soluong'], $_POST['ngaynhap']);
				echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			}
			$listhang['list'] = $obctnhap->_getHang();
			$listmathang['list'] = $obctnhap->_getMatHang();
			require 'views/admin/chitietnhap/add.php';
			break;
		}
		case 'del_ctnhap':{
			$obctnhap->_delCTNhap($_GET['ma']);
			echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			break;
		}
		case 'edit_ctnhap':{
			if($_POST){
				$obctnhap->_editCTNhap($_POST['cmb_hang'], $_POST['cmb_mathang'], $_POST['dongia'], $_POST['soluong'], $_POST['ngaynhap'], $_GET['ma']);
				echo '<script>window.location.href="admin.php?mod=ctnhap"</script>';
			}
			$data = $obctnhap->_getCTNhap($_GET['ma']);
			$data['listh'] = $obHang->_listhang();
			$data['listmh'] = $obMh->listMatHang();
			require 'views/admin/chitietnhap/edit.php';
			break;
		}
	}
?>